﻿Imports System
Imports System.ComponentModel.Design.Serialization

Namespace System.Workflow.ComponentModel.Serialization
    Friend Class TypeExtensionSerializer
        Inherits MarkupExtensionSerializer
        ' Methods
        Protected Overrides Function GetInstanceDescriptor(ByVal serializationManager As WorkflowMarkupSerializationManager, ByVal value As Object) As InstanceDescriptor
            Dim extension As TypeExtension = [TryCast](value,TypeExtension)
            If (extension Is Nothing) Then
                Throw New ArgumentException(SR.GetString("Error_UnexpectedArgumentType", New Object() { GetType(TypeExtension).FullName }), "value")
            End If
            If (Not extension.Type Is Nothing) Then
                Return New InstanceDescriptor(GetType(TypeExtension).GetConstructor(New Type() { GetType(Type) }), New Object() { extension.Type })
            End If
            Return New InstanceDescriptor(GetType(TypeExtension).GetConstructor(New Type() { GetType(String) }), New Object() { extension.TypeName })
        End Function

    End Class
End Namespace

